package cn.buk.flight.entity;

import cn.buk.common.util.FlightUtil;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.persistence.Transient;

@Entity
@Table(name="flightinfo_history")
public class FlightInfoHistory {
	@Id
	@GeneratedValue(strategy= GenerationType.IDENTITY)
	private int id;
	
	/**
	 * departure city
	 */
	@Column(name="dcity")
	private String depCity;
	
	/**
	 * arrival city
	 */
	@Column(name="acity")
	private String arrCity;
	
	@Column(name="dport")
	private String depPort;
	
	@Column(name="aport")
	private String arrPort;
	
	/**
	 * departure terminal
	 * 出发航站楼
	 */
	@Column(name="dTerm")
	private String depTerminal;
	
	@Column(name="aTerm")
	private String arrTerminal;
	
	private String flightNo;

	@Temporal(TemporalType.DATE)
	@Column(name="dDate")
	private Date depDate;
	
	@Temporal(TemporalType.DATE)
	@Column(name="aDate")	
	private Date arrDate;
	
	@Column(name="dTime")
	private String depTime;
	
	@Column(name="aTime")
	private String arrTime;

	/**
	 * Aircraft Type
	 */
	@Column(name="craftType")
	private String planeType;
	
	@Transient
	private String depPortName;
	@Transient
	private String arrPortName;
	@Transient
	private String depCityName;
	@Transient
	private String arrCityName;
	
	/**
	 * 机场建设税
	 */
	private int taxCN;
	
	/**
	 * 燃油附加费
	 */
	private int taxYQ;
	
	/**
	 * 经停
	 */
	private String stopover;
	
	/**
	 * 航班上是否提供餐食
	 */
	@Column(name="meats")
	private String dinner;
		
	/**
	 * 物理舱位
	 */
	@Column(length=1)
	private String cabinclass;
	
	/**
	 * 子舱位
	 */
	private String subclass;
	
	/**
	 * 舱位折扣
	 */
	private int offset;
	/**
	 * 舱位折扣
	 */
	private String subclassDesc;
	
	/**
	 * 标识价格
	 */
	private int fcny;
	
	/**
	 * 实收价格
	 */
	private int scny;

    /**
     * 返利金额
     */
    @Column(name="rebate_amount")
    private int rebateAmount;

    /**
     * 提前多少天预定
     */
    @Column(name="before_fly_date")
    private int beforeFlyDate;

	/**
	 * 座位数
	 */
	private int seatCount;
	
	private int b2cHost;
	private String b2cBooking;


    /**
     * 出发机场截至值机时间
     */
    private Integer dportCheckInTime;


	/**
	 * F舱座位数
	 */
	@Column(name = "f_count")
	private int fclassCount;
	/**
	 * P舱座位数
	 */
	@Column(name = "p_count")
	private int pclassCount;
	/**
	 * A舱座位数
	 */
	@Column(name = "a_count")
	private int aclassCount;

	/**
	 * y舱座位数
	 */
	@Column(name = "y_count")
	private int yclassCount;

	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime;

	@Temporal(TemporalType.TIMESTAMP)
	private Date lastupdate;



    /**
     * 该航班最低价的退改签说明
     */
    @Transient
    private String rernote;
    @Transient
    private String endnote;
    @Transient
    private String refnote;
    @Transient
    private int flightDetailId;
    @Transient
    private List<FlightPrice> priceList = new ArrayList<>();
    @Transient
    private String carrierCode;
    @Transient
    private String carrierName;


    public String getCabinClassDesc() {
		return FlightUtil.getCabinClassDesc(cabinclass);
	}
	
	public String getOffsetDesc() {
		return FlightUtil.getOffsetDesc(offset);
	}

    public String getShowDepTime() {
        return FlightUtil.formatShowTime(this.depTime);
    }

    public String getShowArrTime() {
        return FlightUtil.formatShowTime(this.arrTime);
    }

	/**
	 * @param stopover the stopover to set
	 */
	public void setStopover(String stopover) {
		this.stopover = stopover;
	}
	/**
	 * @return the stopover
	 */
	public String getStopover() {
		return stopover;
	}
	/**
	 * @param subclass the subclass to set
	 */
	public void setSubclass(String subclass) {
		this.subclass = subclass;
	}
	/**
	 * @return the subclass
	 */
	public String getSubclass() {
        if (subclass == null) {
          return null;
        } else {
          return subclass.trim();
        }
	}

	public void setId(int id) {
		this.id = id;
	}
	public int getId() {
		return id;
	}
	

	public void setFlightNo(String flightNo) {
		this.flightNo = flightNo;
	}
	public String getFlightNo() {
        if (flightNo == null) {
          return "";
        } else {
          return flightNo.trim();
        }
	}
	
	public void setTaxCN(int taxCN) {
		this.taxCN = taxCN;
	}
	public int getTaxCN() {
		return taxCN;
	}
	public void setTaxYQ(int taxYQ) {
		this.taxYQ = taxYQ;
	}
	public int getTaxYQ() {
		return taxYQ;
	}
	public void setDinner(String dinner) {
		this.dinner = dinner;
	}
	public String getDinner() {
		return dinner;
	}
	public void setSubclassDesc(String subclassDesc) {
		this.subclassDesc = subclassDesc;
	}
	public String getSubclassDesc() {
		return subclassDesc;
	}
	
	public void setSeatCount(int seatCount) {
		this.seatCount = seatCount;
	}
	public int getSeatCount() {
		return seatCount;
	}
	public void setB2cHost(int b2cHost) {
		this.b2cHost = b2cHost;
	}
	public int getB2cHost() {
		return b2cHost;
	}
	public void setB2cBooking(String b2cBooking) {
		this.b2cBooking = b2cBooking;
	}
	public String getB2cBooking() {
		return b2cBooking;
	}
	public void setScny(int scny) {
		this.scny = scny;
	}
	public int getScny() {
		return scny;
	}
	public void setFcny(int fcny) {
		this.fcny = fcny;
	}
	public int getFcny() {
		return fcny;
	}

	public String getPlaneType() {
		return planeType;
	}
	public void setPlaneType(String planeType) {
		this.planeType = planeType;
	}
	
	public String getCarrierCode() {
		if (carrierCode == null) {
			carrierCode = flightNo.substring(0, 2);
		}

		return carrierCode;
	}
	public String getDepCity() {
		return depCity;
	}
	public void setDepCity(String depCity) {
		this.depCity = depCity;
	}
	public String getArrCity() {
		return arrCity;
	}
	public void setArrCity(String arrCity) {
		this.arrCity = arrCity;
	}
	public String getDepPort() {
		return depPort;
	}
	public void setDepPort(String depPort) {
		this.depPort = depPort;
	}
	public String getArrPort() {
		return arrPort;
	}
	public void setArrPort(String arrPort) {
		this.arrPort = arrPort;
	}
	public String getDepTerminal() {
		return depTerminal;
	}
	public void setDepTerminal(String depTerminal) {
		this.depTerminal = depTerminal;
	}
	public String getArrTerminal() {
		return arrTerminal;
	}
	public void setArrTerminal(String arrTerminal) {
		this.arrTerminal = arrTerminal;
	}
	public Date getDepDate() {
		return depDate;
	}
	public void setDepDate(Date depDate) {
		this.depDate = depDate;
	}
	public Date getArrDate() {
		return arrDate;
	}
	public void setArrDate(Date arrDate) {
		this.arrDate = arrDate;
	}
	public String getArrTime() {
        if (arrTime == null) {
          return "";
        } else {
          return arrTime.trim();
        }
	}
	public void setArrTime(String arrTime) {
		this.arrTime = arrTime;
	}
	public String getDepTime() {
        if (depTime == null) {
          return "";
        } else {
          return depTime.trim();
        }
	}
	public void setDepTime(String depTime) {
		this.depTime = depTime;
	}
	public String getDepPortName() {
        if (depPortName == null) {
          return "";
        } else {
          return depPortName.trim();
        }
	}
	
	public void setDepPortName(String depPortName) {
		this.depPortName = depPortName;
	}
	
	public String getArrPortName() {
        if (arrPortName == null) {
          return "";
        } else {
          return arrPortName.trim();
        }
	}
	
	public void setArrPortName(String arrPortName) {
		this.arrPortName = arrPortName;
	}
	
	
	
	/**
	 * @return the cabinclass
	 */
	public String getCabinclass() {
		return cabinclass;
	}
	/**
	 * @param cabinclass the cabinclass to set
	 */
	public void setCabinclass(String cabinclass) {
		this.cabinclass = cabinclass;
	}
	/**
	 * @return the offset
	 */
	public int getOffset() {
		return offset;
	}
	/**
	 * @param offset the offset to set
	 */
	public void setOffset(int offset) {
		this.offset = offset;
	}

    public List<FlightPrice> getPriceList() {
        return priceList;
    }

    public void setPriceList(List<FlightPrice> priceList) {
        this.priceList = priceList;
    }

    public int getRebateAmount() {
        return rebateAmount;
    }

    public void setRebateAmount(int rebateAmount) {
        this.rebateAmount = rebateAmount;
    }

    public int getBeforeFlyDate() {
        return beforeFlyDate;
    }

    public void setBeforeFlyDate(int beforeFlyDate) {
        this.beforeFlyDate = beforeFlyDate;
    }

    public int getDportCheckInTime() {
        return dportCheckInTime == null? 0 : dportCheckInTime.intValue();
    }

    public void setDportCheckInTime(int dportCheckInTime) {
        this.dportCheckInTime = dportCheckInTime;
    }


    public String getRernote() {
        return rernote;
    }

    public void setRernote(String rernote) {
        this.rernote = rernote;
    }

    public String getEndnote() {
        return endnote;
    }

    public void setEndnote(String endnote) {
        this.endnote = endnote;
    }

    public String getRefnote() {
        return refnote;
    }

    public void setRefnote(String refnote) {
        this.refnote = refnote;
    }

    public int getFlightDetailId() {
        return flightDetailId;
    }

    public void setFlightDetailId(int flightDetailId) {
        this.flightDetailId = flightDetailId;
    }

    public String getCarrierName() {
        if (this.carrierName == null) {
          return "";
        } else {
          return carrierName.trim();
        }
    }

    public void setCarrierName(String carrierName) {
        this.carrierName = carrierName;
    }

	public String getDepCityName() {
		return depCityName;
	}

	public void setDepCityName(String depCityName) {
		this.depCityName = depCityName;
	}

	public String getArrCityName() {
		return arrCityName;
	}

	public void setArrCityName(String arrCityName) {
		this.arrCityName = arrCityName;
	}

	public Date getLastupdate() {
		return lastupdate;
	}

	public void setLastupdate(Date lastupdate) {
		this.lastupdate = lastupdate;
	}

	public int getFclassCount() {
		return fclassCount;
	}

	public void setFclassCount(int fclassCount) {
		this.fclassCount = fclassCount;
	}

	public int getPclassCount() {
		return pclassCount;
	}

	public void setPclassCount(int pclassCount) {
		this.pclassCount = pclassCount;
	}

	public int getAclassCount() {
		return aclassCount;
	}

	public void setAclassCount(int aclassCount) {
		this.aclassCount = aclassCount;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public int getYclassCount() {
		return yclassCount;
	}

	public void setYclassCount(int yclassCount) {
		this.yclassCount = yclassCount;
	}
}
